package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Test2 {
    public static void main(String[] args) {
        UserInfo userInfo = InputUtil.getInputObject(new UserInfo(), "删除", "删除");
        System.out.println(userInfo);

        try (
                Connection conn = DBUtil.getConnection();
        ) {
            String str = "DELETE FROM userinfo WHERE username = ?";
            PreparedStatement ps = conn.prepareStatement(str);
            ps.setString(1, userInfo.getUsername());
            int num = ps.executeUpdate();
            if (num > 0) {
                System.out.println("删除成功");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }


    }
}
